//
//  LXDetailsHeaderView.m
//  灵秀
//
//  Created by 李田 on 17/3/19.
//  Copyright © 2017年 tianyao. All rights reserved.
//

#import "LXDetailsHeaderView.h"
#import "LXFoodDetailModel.h"
@interface LXDetailsHeaderView ()
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UIButton *buyCarBtn;

@end

@implementation LXDetailsHeaderView

- (IBAction)buyCarBtnAction:(UIButton *)sender {
    
    // 转换坐标
    UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
    
    CGPoint startP = [self convertPoint:sender.center toView:keyWindow];
    
    // 注册通知
    NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
    
    // 发送通知
    NSDictionary *dic = @{
                          @"startP":[NSValue valueWithCGPoint:startP],
                          @"model":_model
                          };
    
    [notificationCenter postNotificationName:kNotificationNamePageVcBuyCarView object:self userInfo:dic];
}
#pragma mark - 2.0赋值
- (void)setModel:(LXFoodDetailModel *)model
{
    _model = model;
    
    _nameLabel.text = model.name;
}


#pragma mark - 1.0 类方法
+ (instancetype)detailsHeadView
{
    
    return [[[NSBundle mainBundle] loadNibNamed:@"LXDetailsHeaderView" owner:nil options:nil] lastObject];
}

- (void)awakeFromNib
{
    [super awakeFromNib];
    
    //设置圆角
    _buyCarBtn.layer.cornerRadius = 2;
    _buyCarBtn.layer.masksToBounds = YES;
}

@end
